<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.Map.Entry"%>
<%@page import="java.lang.reflect.Method"%>
<%@page import="cn.edu.zjut.chopper.message.RemoteInterface"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Remote Interface Invoke Result</title>
</head>
<body style="background-color: #AFEEEE; text-align: center;">
<jsp:include page="head.html"/>
<table width="800" align="center" >
	<tr style="background-color: #969696">
		<td><table align="center"><tr><td style="font-size:20pt;">Remote Interface Invoke Result</td></tr></table></td>
	</tr>
<%
	RemoteInterface ri = (RemoteInterface)request.getAttribute("remote_interface"); 
	Method method = (Method)request.getAttribute("method"); 
	Map<String,String> paramMap = (Map<String,String>)request.getAttribute("param_map");
	String result = (String)request.getAttribute("result");
	out.println("<tr><td><table width=\"100%\">");
	out.println("<tr  style=\"background-color:#90EE90;\"><td width=\"25%\" style=\"font-weight:bold\">Registry Key:</td><td width=\"25%\">"+ri.getName()+"</td><td width=\"25%\" style=\"font-weight:bold \">Version:</td><td width=\"25%\">"+ri.getVersion()+"</td></tr>");
	out.println("<tr  style=\"background-color:#90EE90;\"><td width=\"25%\" style=\"font-weight:bold\">Class Name:</td><td width=\"25%\">"+ri.getInterfaceClassName()+"</td><td width=\"25%\" style=\"font-weight:bold \">Invoke Count:</td><td width=\"25%\">"+ri.getCount()+"</td></tr>");
	out.println("<tr  style=\"background-color:#90EE90;\"><td width=\"25%\" style=\"font-weight:bold\">Url:</td><td width=\"75%\" colspan=\"3\">"+ri.getUrl()+"</td></tr>");
	out.println("<tr  style=\"background-color:#90EE90;\"><td width=\"25%\" style=\"font-weight:bold\">Note:</td><td width=\"75%\" colspan=\"3\">"+ri.getNote()+"</td></tr>");
	out.println("</table></td></tr>");
	out.println("<tr><td><table  width=\"100%\">");
	out.println("<tr style=\"background-color: #FFFF99;\"><td width=\"20%\" style=\"font-weight:bold\" >Return Type</td><td width=\"20%\" style=\"font-weight:bold\">Method name</td><td width=\"60%\" style=\"font-weight:bold\">Parameters</td></tr>");
	String returnType = method.getReturnType().toString();
	out.println("<tr style=\"background-color: #FFFF99;\"><td width=\"20%\">"+returnType.substring(returnType.lastIndexOf(".")+1,returnType.length())+"</td><td width=\"20%\">"+method.getName()+"</td><td width=\"60%\" align=\"left\">");
	for(Entry<String,String> paramEntry:paramMap.entrySet()){
		out.println(paramEntry.getKey().substring(paramEntry.getKey().lastIndexOf(".")+1,paramEntry.getKey().length())+" : "+paramEntry.getValue()+"&nbsp;");
	}
	out.println("</td></tr>");
	out.println("</table></td></tr>");
	out.println("<tr><td><table  width=\"100%\" align=\"left\">");
	String resultString = result==null?"null":result.toString();
	out.println("<tr style=\"background-color:#FFFF99;\"><td width=\"20%\" style=\"font-weight:bold\">Result:</td><td width=\"80%\">"+resultString+"<td/></tr>");
	out.println("</table></td></tr>");

%>
</table>
<jsp:include page="foot.html"/>
</body>
</html>